import ajax from './ajax'

const BASE_URL = 'http://localhost:3000/api'

//查询全部用户
export const reqUser = () => ajax(BASE_URL + '/user')

//添加用户
export const reqAddUser = (user) => ajax(BASE_URL + '/user/add', user, 'POST')

//删除用户
export const reqRemoveUser = (user) => ajax(BASE_URL + '/user/delete/' + user.id, {}, 'DELETE')

//查询单个用户
export const reqSearchSingleUser = (id) => ajax(BASE_URL + '/user/singleUser/' + id)

//修改用户
export const reqEditUser = (user) => ajax(BASE_URL + '/user/update/' + user._id, user, 'POST')

//获取新闻列表
export const reqNews = () => ajax(BASE_URL + '/news')

//添加新闻
export const reqAddNews = (news) => ajax(BASE_URL + '/news/add', news, 'POST')

//获取单个新闻
export const reqSingleNews = (id) => ajax(BASE_URL + '/news/search/' + id)

//修改新闻
export const reqEditNews = (news) => ajax(BASE_URL + '/news/update/' + news._id, news, 'POST')

//删除新闻
export const reqRemoveNews = (id) => ajax(BASE_URL + '/news/delete/' + id, {}, 'DELETE')

//搜索新闻
export const reqSearchNews = (keyword) => ajax(BASE_URL + '/news/search/', keyword, 'POST')

//获取主题
export const reqTopic = () => ajax(BASE_URL + '/topic')

//添加主题
export const reqAddTopic = (topic) => ajax(BASE_URL + '/topic/add', topic, 'POST')

//删除主题
export const reqRemoveTopic = (topic) => ajax(BASE_URL + '/topic/delete/' + topic, {}, 'DELETE')

//获取今日要闻
export const reqTodayNews = () => ajax(BASE_URL + '/news/todayNews/')

//获取今日要闻
export const reqSidebar = () => ajax(BASE_URL + '/news/sidebar/')

//用户登录
export const reqLogin = (user) => ajax(BASE_URL + '/user/login', user, 'POST')

//获取所有评论
export const reqComments = () => ajax(BASE_URL + '/comment/')

//关键词查询评论
export const reqSearchComments = (keyword) => ajax(BASE_URL + '/comment/search', keyword, 'POST')

//删除评论
export const reqRemoveComments = (id) => ajax(BASE_URL + '/comment/delete/' + id, {}, 'DELETE')

//新闻id查询评论
export const reqNewsComments = (id) => ajax(BASE_URL + '/comment/newsId/' + id)

//发表评论
export const reqAddComment = (comments) => ajax(BASE_URL + '/comment/add/', comments, 'POST')

//获取验证码
export const reqSendCode = (phone) => ajax(BASE_URL + '/user/sendcode/', phone)

//修改密码
export const reqEditPassword = (userInfo) => ajax(BASE_URL + '/user/forget/', userInfo, 'POST')